<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title></title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			.aaa{
				width: 100%;
				height: 100px;
				background: #ededed;
				position: relative;
			}
			p{
				background: red;
				position: absolute;
				bottom: 0;
				width: 100%;
			}
		</style>
	</head>
	<body>
		<div class="aaa">
			111
			<p class="btn">2222</p>
		</div>
	</body>
</html>
<script src="js/jquery-3.2.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	let btn = document.querySelector('.btn')
	let aaa = document.querySelector('.aaa')
	drag($('.btn'))
	function drag(obj){
		obj.on('mousedown touchmove',start);
		
		function start(event){
			console.log('按下', event)
			
			// div左上角的坐标
			deltaX = event.clientX - obj.offset().left;
			deltaY = event.clientY - obj.offset().top;
			
			// 将移动事件绑定在document上，避免bug					
			$(document).bind('mousemove',move);
			$(document).bind('mouseup',stop);
			
			return false;
		}
		
		// 这个位置不加参数，在火狐不能用
		function move(e){
			$('.aaa').css({
				'height':(e.clientY-deltaY) + 21 +'px',
			})
		}
		
		function stop(){
			$(document).unbind('mousemove',move)
		}
	}
</script>  